package com.company.example.customEditor;

import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.propertyeditors.CustomDateEditor;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by ywl on 2017/1/4.
 */
public class DatePropertyEditorRegistrar implements PropertyEditorRegistrar {
    private String format;

    public void setFormat(String format) {
        this.format = format;
    }

    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
        registry.registerCustomEditor(Date.class,new CustomDateEditor(new SimpleDateFormat(format),true));
    }
}
